/*
**  Copyright (c) 2014 Michael Liu(michael.liu.point@gmail.com).
**
**  Project: Gateway Unified Management Platform
**  File:      svcmgr.h
**  Author:  Michael
**  Date:    03/20/2014
**
**  Purpose:
**    service manager related defines.
*/

#ifndef __SVC_MGR_H__
#define __SVC_MGR_H__

#ifdef __cplusplus
extern "C" {
#endif				/* __cplusplus */

/* Include files. */

#include "common.h"
#include "list.h"
#include "osdep.h"

/* Macro constant definitions. */

#define SYSMGR_SERVICE_NAME_SIZE	(64)
#define SYSMGR_SERVICE_ARG_COUNTER	(16)
#define SYSMGR_SERVICE_MAX			(16)

#define SYSMGR_SVC_HTTPD			"http-server"
#define SYSMGR_SVC_NBNSD			"netbios_svc"
#define SYSMGR_SVC_DNSMASQ			"dnsmasq"
#define SYSMGR_SVC_NTPCLIENT		"ntp-client"
#define SYSMGR_SVC_DHCPC_FORMAT		"%s-dhcp-client"

#define DNSMASQ_DHCPD_CONF_FILE				"/tmp/dhcpd.conf"
#define DNSMASQ_DHCPD_HOSTS_CONF_FILE		"/tmp/dhcpd_hosts.conf"
#define DNSMASQ_DNS_ADDRESS_CONF_FILE		"/tmp/address.conf"

/* Type definitions. */

	typedef struct _sm_svc tsm_svc;

	typedef e_ret(*sm_svc_start) (tsm_svc * svc);
	typedef e_ret(*sm_svc_reload) (tsm_svc * svc);

	struct _sm_svc {
		struct list_head list;
		tos_dep_task task;
		tos_dep_mutex mutex;
		e_bool enable;
		char name[SYSMGR_SERVICE_NAME_SIZE];
		sm_svc_start start;
		sm_svc_reload reload;
		void *priv;
	};

	typedef struct {
		void *dp;
		void *dp_if;
		void *dp_rule;
	} tdnsmasq_svc_priv;

/* External function declarations. */

	extern e_ret svcmgr_init();
	extern e_ret svcmgr_check();

	e_ret svcmgr_add_svc(tsm_svc * svc);
	e_ret svcmgr_del_svc(tsm_svc * svc);
	e_ret svcmgr_find_svc(const char *name, tsm_svc ** svc);

/* Macro API definitions. */

/* Global variable declarations. */

#ifdef __cplusplus
}				/* extern "C" */
#endif				/* __cplusplus */
#endif				/* __SVC_MGR_H__ */
